import { request } from '@/utils/request';
import CRUD from '@/utils/request/CRUD';

// 角色CRUD
export const roleCRUD = CRUD('/system/role');

// 获取精简角色列表
export function getSimpleRoleList() {
  return request.get({
    url: '/system/role/simple-list',
  });
}

// 根据用户id获取角色
export function getRoleByUserId(params: any) {
  return request.get({
    url: '/system/permission/list-user-roles',
    params,
  });
}

// 设置用户角色
export function setUserRole(data: any) {
  return request.post({
    url: '/system/permission/assign-user-role',
    data,
  });
}

// 根据角色id获取菜单
export function getMenuByRoleId(params: any) {
  return request.get({
    url: '/system/permission/list-role-menus',
    params,
  });
}

// 设置角色菜单
export function setRoleMenu(data: any) {
  return request.post({
    url: '/system/permission/assign-role-menu',
    data,
  });
}

// 设置数据权限
export function setDataPermission(data: any) {
  return request.post({
    url: '/system/permission/assign-role-data-scope',
    data,
  });
}
